using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;
using TONLI.TJOA.Common;

namespace TONLI.TJOA.Anquan {
    public partial class AQK_Html : System.Web.UI.Page {
        protected void Page_Load(object sender, EventArgs e) {
            if (!IsPostBack) {
                LoadData(Request["suid"],Request["col"],Request["table"]);
            }
        }
        public void LoadData(string uid, string col, string tablename) {
          
            Hashtable ps = new Hashtable();
            ps["SUID"] = uid;
            ps["COLNAME"] = col;
            ps["TABLENAME"] = tablename;
            Hashtable table1 = (Hashtable)DataService.BaseService().GetObject("SelectTJOA_IMAGEByKey", ps);
           
            string date2 = Convert.ToDateTime(table1["DATE2"]).ToString("yyyy-MM-dd");
            string src = "../temp/" + date2 + ".doc";
            if (table1 != null ) {
                byte[] buff=(byte[])table1["CONTENT"];
                if (buff.Length > 0) {
                    string html = GZipHelper.UnCompressToString(buff);
                    string filename = HttpContext.Current.Server.MapPath(src);
                    StreamWriter sw = new StreamWriter(File.Create(filename), System.Text.Encoding.Default);
                    sw.Write(html);
                    sw.Flush();
                    sw.Close();
                    div1.InnerHtml = html;// string.Format("<iframe id='ifame1' frameborder=\"0\" width=\"{0}\" height=\"{1}\" src=\"{2}\" runat=server></iframe>", "100%", "98%", src);
                    HyperLink1.NavigateUrl = src;
                }
            }
        }

      
    }
}
